const app = getApp();
var util = require('../../utils/util.js');
Page({

    /**
     * 页面的初始数据
     */
    data: {

        bsly: 0,
        date: '2022-01-10',
        date1: '2022-01-10',
        swiperImgUrls: [//没什么用的装饰品。
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Fa79e291099ac011b04abcb9bc794af52bb6f04271be6aa-REUjbL_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639314033&t=c8f4cb42238d0246e1b0f7526a5d8112',
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fhbimg.b0.upaiyun.com%2Ffa1438c6327b9c5587d343a7d5c63bf44ff0f59433bd2-J9SfRb_fw658&refer=http%3A%2F%2Fhbimg.b0.upaiyun.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639314033&t=572aecedd36a681555b7ccc86cdca2fe',
            'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fdesk-fd.zol-img.com.cn%2Ft_s960x600c5%2Fg5%2FM00%2F02%2F07%2FChMkJlbKy1GAKCQ-ARabe7z3JEM305.jpg&refer=http%3A%2F%2Fdesk-fd.zol-img.com.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1639314033&t=187e27939489c620db54c954c6b0f9b1'
        ],
        swiperCurrent: 0,
    },

    swiperChange(e) {
        const that = this;
        that.setData({
          swiperCurrent: e.detail.current
        })
      },
    
      /**
       * 图片手动滑动时，获取当前的轮播id
       */
      imageChange(e) {
        const that = this;
        that.setData({
          swiperCurrent: e.currentTarget.id
        })
      },

    

//后端搜索，不过绑定到这个触发方法，是不是太频繁了？
    bindinput: function (event) {
        console.log(event.detail.value);
        var that = this;
        wx.request({
            url: app.globalData.headurl + '/Spot/selectBufoodByName',
            data: {
                name: event.detail.value
            },
            method: 'POST',
            header: {
                'content-type': 'application/x-www-form-urlencoded' // 默认值 
            },
            success: function (res) {
                console.log("res:" + res.data.length)
                that.setData({
                    Spotlist: res.data,
                })

            }
        })
    },

  
//点击跳转到详情页面
    toDetailsTap: function (e) {
        var id = e.currentTarget.dataset.id;
        wx.navigateTo({
            url: '../goods-details/index?id=' + id,
        })
    },

  

    /**
     * 加载的时候请求所有的景点。。。。
     */
    onLoad: function (options) {
        var that = this;
        var dtime = util.formatTime(new Date());
        console.log("dtime:" + dtime)
        wx.request({
            url: app.globalData.headurl + '/Spot/selectAllSpot',
            success: function (res) {
                console.log("res:" + res.data.length)
                that.setData({
                    Spotlist: res.data,
                })

            }
        });


     

    },


    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        var that = this



    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    }
})